<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Victor
 * Date: 08.12.11
 * Time: 14:07
 * To change this template use File | Settings | File Templates.
 */

class User_Manager extends Core_BaseModel
{


    public function getUserInformation($auth)
    {
        //echo "getUserInformation($auth)<br/>";
        $authManager = new Auth_Auth2();
        if($auth['auth'] != false){
            $name = $auth['name'];
            $idAccount = $authManager->getUserIdByLogin($name);
        }
        if($idAccount == -1) return;

       try{ $pdo = $this->dataModule->getConnection();
        $sql = "SELECT `iduserProfile`,`name`,`surname`,`patronym` FROM `dzundza_userprofile`
where `edu_account_idaccount` = :idAccount";
        $stn = $pdo->prepare($sql);
        $stn->bindParam(':idAccount', $idAccount, PDO::PARAM_INT);
        $stn->execute();
        $result = $stn->fetch(PDO::FETCH_ASSOC);

        return $result;
         }catch(PDOException $e){
           echo "[ERROR]getUserInformation()   - $e /n";

       }

    }

    public function getUserIdProfileById($idLogin)
    {
        //echo "getUserIdProfileById($idLogin)/n";
        $pdo = $this->dataModule->getConnection();
        $sql = "select `iduserProfile` from `dzundza_userprofile`
      where `edu_account_idaccount` = :idLogin";
        $stn = $pdo->prepare($sql);
        $stn->bindParam(':idLogin', $idLogin, PDO::PARAM_INT);
        $stn->execute();
        $result = $stn->fetch(PDO::FETCH_ASSOC);
        return $result['iduserProfile'];


    }

}
